include<ub.scad>; //⇒ v.gd/ubaer or https://github.com/UBaer21/UB.scad
/*[Hidden]*/
designVersion="1.0";
designer="Ulrich Bär";
license="CC0";
useVersion=23.340;//(sites.google.com/site/ulrichbaer)
assert(Version>=useVersion,str("lib version ",Version," detected, include ",useVersion," ub.scad library‼ ⇒http://v.gd/ubaer"));
/*[Basics]*/
nozzle=.2;
bed=false;
pPos=[0,0];
info=true;
name=undef;

/*[G1 nut]*/
flangeD=38;
hex=false;

T(printPos)G1nut(flangeD,hex=hex);


module G1nut(d=38,h=12,dicke=2,hex=0){
  ir=10.65;
  hexD=umkreis(6,is_num(hex)?hex:28);
  deg=45;
  
  points=[
  [ir,0],
  [d/2,0],
  [d/2,dicke],
  [ir+dicke,(d/2-ir-dicke)*tan(deg)],
  [ir+dicke,h],
  [ir,h],
  ];
  difference(){
    union(){
      Gewinde(preset="BSW1",h=h-1,innen=true,spiel=.2,tz=.75,dicke=dicke-.2);
      RotEx()Rund(.75,2)polygon(points);
      if(hex)Roof(h,1)difference(){
        Rund(1,0)circle(d=hexD,$fn=6);
        circle(r=ir);
      }
      else Polar(6,ir)R(90)Roof(2.5,.5*[1,1],center=true)Quad([d/2-ir-.2,h],r=2,center=[0,0]);
    }
    Kegel(r1=ir+.25,r2=ir-.5,lap=[10,0]);
    Tz(-50)cylinder(r=ir*2,h=50,$fn=6);
  }
}
// version Info
if(string2num(designVersion[2])>0)T(1,-1)color("navy")linear_extrude(.1)Seg7(str(designVersion),h=1,spiel=0.01,b=.05,ratio=0.5,center=true,name=0);